import 'package:flutter/material.dart';
import 'package:flutter_09_game/base/controller/base_controller.dart';
import 'package:flutter_09_game/generated/locales.g.dart';
import 'package:flutter_09_game/pages/deposit/deposit_record/deposit_record_commission/deposit_record_commission_logic.dart';
import 'package:flutter_09_game/pages/deposit/deposit_record/deposit_record_commission/deposit_record_commission_view.dart';
import 'package:flutter_09_game/pages/deposit/deposit_record/deposit_record_recharge/deposit_record_recharge_logic.dart';
import 'package:flutter_09_game/pages/deposit/deposit_record/deposit_record_recharge/deposit_record_recharge_view.dart';
import 'package:flutter_09_game/pages/deposit/deposit_record/deposit_record_team/deposit_record_team_list/deposit_record_team_list_logic.dart';
import 'package:flutter_09_game/pages/deposit/deposit_record/deposit_record_team/deposit_record_team_logic.dart';
import 'package:flutter_09_game/pages/deposit/deposit_record/deposit_record_team/deposit_record_team_view.dart';
import 'package:flutter_09_game/pages/deposit/deposit_record/deposit_record_withdraw/deposit_record_withdraw_logic.dart';
import 'package:flutter_09_game/pages/deposit/deposit_record/deposit_record_withdraw/deposit_record_withdraw_view.dart';
import 'package:flutter_09_game/widgets/tab/common_tab_bar_page.dart';
import 'package:get/get.dart';

class DepositRecordLogic extends BaseController
    with GetSingleTickerProviderStateMixin {
  late TabController tabController;

  List<CommonTabModel> tabs = [
    CommonTabModel(
        view: DepositRecordRechargePage(), title: LocaleKeys.recharge.tr),
    CommonTabModel(
        view: DepositRecordWithdrawPage(), title: LocaleKeys.withdraw.tr),
    CommonTabModel(view: DepositRecordTeamPage(tag: '1',), title: LocaleKeys.team.tr),
    CommonTabModel(
        view: DepositRecordCommissionPage(), title: LocaleKeys.commission.tr),
  ];

  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();
    tabController = TabController(length: tabs.length, vsync: this);
    // tabController.addListener(_tabListener);
  }

  // void _tabListener() {
  //   // if (!tabController.indexIsChanging) {
  //   //   if (tabController.index == 0) {
  //   //     if (Get.isRegistered<DepositRecordRechargeLogic>()) {
  //   //       Get.find<DepositRecordRechargeLogic>().refreshList();
  //   //     }
  //   //   } else if (tabController.index == 1) {
  //   //     if (Get.isRegistered<DepositRecordWithdrawLogic>()) {
  //   //       Get.find<DepositRecordWithdrawLogic>().refreshList();
  //   //     }
  //   //   } else if (tabController.index == 2) {
  //   //     if (Get.isRegistered<DepositRecordTeamLogic>()) {
  //   //       Get.find<DepositRecordTeamLogic>().updateOfCurrentLogic();
  //   //     }
  //   //   } else if (tabController.index == 3) {
  //   //     if (Get.isRegistered<DepositRecordCommissionLogic>()) {
  //   //       Get.find<DepositRecordCommissionLogic>().refreshList();
  //   //     }
  //   //   }
  //   // }
  // }

  // void updateTabLogic<T>() {
  //   if (Get.isRegistered<T>()) {
  //     Get.find<T>()!.refreshList();
  //   }
  // }

  @override
  void onReady() {
    // TODO: implement onReady
    super.onReady();
  }

  @override
  void onClose() {
    // tabController.removeListener(_tabListener);
    tabController.dispose();
    super.onClose();
  }
}
